$(function () {
    obj.init();
});
var obj = new function () {
    return {
        id: null,
        form: null,
        city: null,
        district: null,
        init: function () {
            this.form = new xhForm($('#xh_form'));
            this.listener();
        },
        listener: function () {
            var $this = this;
            $('#bt_modal_confirm',parent.document).click(function () {
                $this.funObj().saveData();
            });

            $('.thumbnail').click(function () {
                var check = $(this).find('.check-status');
                var input = check.next();

                check.toggleClass('glyphicon-ok');

                if (input.val() == 1) {
                    input.val(0);
                } else {
                    input.val(1);
                }
            })
        },
        funObj: function () {
            var $this = this;
            return {
                saveData:function () {
                    var params = {};
                    if ($this.id) {//修改
                        params.iId = $this.id;
                    }
                    $this.form.submit('home_set/userSetSave', params, function (res) {
                        if(res.code === 200){
                            window.top.xhTop.closeModal();
                            window.top.xhTop.getFrameByName('首页').location.reload();
                        } else {
                            window.top.xhTop.showError(res.error);
                            xhExtra.setBtnNormal($('#bt_modal_confirm',parent.document));
                        }
                    },{check:false,success:true});
                },
            }
        }
    }
};
